package com.seednia.foundation.framework.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

/**
 * Abstract class for all Web (HTML) Request controllers 
 * @author Young Suk Ahn
 *
 */
public abstract class AbstractWebRequestController {

	@InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    }
	
	public RequestContext createRequestContext(HttpServletRequest httpRequest){
		RequestContext retval = new RequestContext();
		// TODO: populate the request context accordingly (maybe use a factory)
		return retval;
	}
}
